package com.langfeiyes.pattern.observer.demo2;

//目标对象：商品
public class ProductObserver extends Subject{

    private String name;
    private boolean state = false;  //约定：false：缺货，true：有货

    public ProductObserver(String name){
        this.name = name;
    }

    //进货
    public void stock(int count){
        System.out.println("商家最新进货，上架商品：" +this.name+ "，共" + count +" 部");
        state = true;
        notifyObservers();
    }

    public boolean getState(){
        return state;
    }

    public String getName() {
        return name;
    }
}
